import { join } from 'path';
import { config } from 'dotenv'
const env = process.env.NODE_ENV || 'test'
console.log('当前环境', process.env.NODE_ENV)

const envPath = join(__dirname, `../../.env.${env}`);
config({ path: envPath });


//类型验证(实际项目建议使用更严格的校验库如 zod)
const getConfig = (): any => ({
    NODE_ENV: process.env.NODE_ENV,
    DB_HOST: process.env.DB_HOST,
    DB_USERNAME: process.env.DB_USERNAME,
    DB_PASSWORD: process.env.DB_PASSWORD,
    DB_DATABASE: process.env.DB_DATABASE,
    MQTT_SHANGHAI_HOST: process.env.MQTT_SHANGHAI_HOST,
    MQTT_SUZHOU_HOST: process.env.MQTT_SUZHOU_HOST,
    CRYPTO_KEY: process.env.CRYPTO_KEY,
    CRYPTO_IV: process.env.CRYPTO_IV,
    CRYPTO_SH_KEY: process.env.CRYPTO_SH_KEY,
    CRYPTO_SH_IV: process.env.CRYPTO_SH_IV,
});
// 导出配置对象
export const envConfig = getConfig();